package io操作;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class 字节流复制文件 {

    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("C:/Test/1.txt");
        FileOutputStream fos = new FileOutputStream("C:/1_copy.txt");
        byte[] bytes = new byte[1024*8];
        int len;
        while((len=fis.read(bytes))!=-1){
            //字节数组中0~len范围是读取的数据，就同时往输出流写数据
            fos.write(bytes, 0, len);
            fos.flush();
        }
        fos.close();
        fis.close();
    }
}
